﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GeneralClasses;

namespace Algorithm
{
    /// <summary>
    /// A constraint that checks if the total salaries of the nurses exceed the salary cap.
    /// </summary>
    public class ExceedsSalaryCapConstraint : Constraint
    {
        private float salaryCap;
        private float[] nurseSalaries;

        public float SalaryCap
        {
            get
            {
                return salaryCap;
            }
            set
            {
                salaryCap = value;
            }
        }

        public float[] NurseSalaries
        {
            get
            {
                return nurseSalaries;
            }
            set
            {
                nurseSalaries = value;
            }
        }

        public ExceedsSalaryCapConstraint(int[] schedule, ScheduleData scheduleData, float points, float salaryCap, 
            float[] nurseSalaries)
            : base(schedule, scheduleData, points)
        {
            this.salaryCap = salaryCap;
            this.nurseSalaries = nurseSalaries;
        }
        
        public override float Evaluate()
        {
            float totalSalaries = 0.0f;

            foreach (int nurseID in schedule)
            {
                totalSalaries += nurseSalaries[nurseID];

                if (totalSalaries > salaryCap)
                    return points;
            }

            return 0.0f;
        }
    }
}
